package net.lzzy.practices.repositories;

import net.lzzy.practices.entities.Course;
import net.lzzy.practices.entities.User;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import java.util.UUID;

/**
 * @author  admin
 */
public interface CourseRepository extends JpaRepository<Course, UUID> {

    List<Course> findAllByOrderByUpdateTimeDesc();

    List<Course> findAllByOrderByUpdateTimeDesc(Pageable pageable);

    List<Course> findCoursesByOpenIsOrderByUpdateTimeDesc(boolean open);

    List<Course> findCoursesByOpenIsOrderByUpdateTimeDesc( Pageable pageable, boolean open);

    Integer countAllBy();
    Integer countCoursesByOpenIs(boolean open);

    List<Course> findCoursesByTeacherIdEqualsOrderByCreateTimeDesc(UUID id);

    List<Course> findCoursesByStudentsContainsAndOpenOrderByUpdateTimeDesc(User student, boolean open);

}
